<?php 
class RelatedProduct extends CWidget {
	// public $catId;
	public $arrayCat = array();
	public $_arrayCatId = array();
	public $currentId;
	public $model = array();
	
	public function init(){
	
		if(!empty($this->arrayCat)){
			foreach($this->arrayCat as $key=>$value){
				$this->_arrayCatId[] = $value->category_id;
			}
		}
		
		$this->model = $this->getRelatedProduct();

		parent::init();
	}
	
	public function getRelatedProduct() {
		$model = Products::model()->getRelatedProduct($this->currentId, $this->_arrayCatId, 0, 3);

		return $model;
	}
	
	public function run(){

		$this->render('related-product',array(
			'model' => $this->model,
		));
	}
}
?>
